package gamble.money.command;

import gamble.money.dao.MoneyDoaImpl;
import gamble.money.vo.MoneyVo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RequestMapping;

public class MoneyChargeController {
	private MoneyDoaImpl dao;
	
	public void setDao(MoneyDoaImpl dao) {
		this.dao = dao;
	}
	@RequestMapping("/chargego.do")
	public String chargego(HttpServletRequest request,MoneyVo vo){
		HttpSession session = request.getSession();
		String id = (String)session.getAttribute("id");
		vo.setId(id);
		vo.setClassify(1);//구분값 1이면 충전
//		System.out.println("세션서 받은 random값 : "+ session.getAttribute("ranNo"));
//		System.out.println("confirm_num : " +vo.getConfirm_num());//입력받은 값
		
		String next ="";
		if(vo.getConfirm_num().equals(session.getAttribute("ranNo") )){
			next = "redirect:/chargelist.do";
			
			if(vo.getPaymobile().equals("opt")){//radio구분
				vo.setInMoney(Integer.parseInt( vo.getMobileselect() ));
				System.out.println("충전 금액 : "+ vo.getMobileselect());
			}else{
				vo.setInMoney(Integer.parseInt( vo.getPay_card_3() ));
				System.out.println("충전 금액 : "+ vo.getPay_card_3());
			}
			
			dao.getInsert(vo);
		}else{
			next = "money/chargemoney";
		}

		return next;
	}
}
